<template>
  <div id="app">
    <ul>
      <!-- 遍历渲染 -->
      <li v-for="(item, ind) in arr" :key="ind">
        <span>{{ item }}</span>
        <button @click="del(ind)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 3],
    };
  },
  methods: {
   add(){
    return this.arr.push(Math.floor(Math.random() * 10))
   },
   del(ind){
    this.arr.splice(ind,1)
   }
  },
};
</script>